// 模拟 lodash 中函数组合的方法 _.flowRight();

const reverse = (array) => array.reverse();
const first = (array) => array[0];
const toUpper = (str) => str.toUpperCase();

const compose = (...args) => (value) =>
    args.reverse().reduce((prev, fn) => fn(prev), value);

const f = compose(toUpper, first, reverse);
console.log(f(['one', 'two', 'three']));

// function compose(...args) {
//     return function(value) {
//         return args.reverse().reduce(function(prev, fn) {
//             return fn(prev);
//         }, value)
//     }
// }
